﻿using Fortunate.Application.Entities;
using Fortunate.IService;
using Fortunate.Service.BASE;
using SqlSugar;
using System.Collections.Immutable;

namespace Fortunate.Service
{
    public class ExeclService : BaseServices<ImportExcel>, IExeclService
    {
        public ExeclService(ISqlSugarClient _db) : base(_db)
        {
        }

        /// <summary>
        /// 导入至数据库存储
        /// </summary>
        /// <param name="excel"></param>
        /// <returns></returns>
        public async Task<bool> ImportExcelAsync(List<ImportExcel> excels)
        {
            return await db.Insertable(excels).ExecuteCommandAsync() > 0;
        }

        /// <summary>
        /// 导出Execl
        /// </summary>
        /// <returns></returns>
        public async Task<List<ImportExcel>> ExportExeclAsync()
        {
            return await db.Queryable<ImportExcel>().OrderBy(x => x.id).Take(30).ToListAsync();
        }

    }
}
